package com.bocloud.cmp.dao.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.bocloud.cmp.dao.HostPerfDao;
import com.bocloud.cmp.entity.resource.HostPerf;
import com.bocloud.common.utils.MapTools;
import com.bocloud.database.core.BasicDao;

/**
 * 性能数据接口
 * 
 * @author oywl
 *
 */
@Repository("hostPerfDao")
public class HostPerfDaoImpl extends BasicDao implements HostPerfDao {
    @Override
    public HostPerf save(HostPerf hostPerf) throws Exception {
        return (HostPerf) this.saveEntity(hostPerf);
    }

    @Override
    public List<HostPerf> listbytype(long vendorId, String hostName) throws Exception {
        // 0 实时 1 小时 2 天 3 周 4 月
        String sql = "select * from host_perf where vendor_id = :vendorId and host_name = :hostName ";
        Map<String, Object> params = MapTools.simpleMap("vendorId", vendorId);
        // params.put("vendorId", vendorId);
        params.put("hostName", hostName);
        List<Object> list = this.queryForList(sql, params, HostPerf.class);
        List<HostPerf> hostPerfs = new ArrayList<>();
        HostPerf hostPerf = null;
        for (Object obj : list) {
            hostPerf = (HostPerf) obj;
            hostPerfs.add(hostPerf);
        }
        return hostPerfs;
    }

}
